/*
 * This controller initiates a test by getting the users questionconfig
 * and generates a questionlist with the proper level on the questions.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chalmers.se.tda367.controller;

import edu.chalmers.se.tda367.model.Test;
import edu.chalmers.se.tda367.model.User;
import edu.chalmers.se.tda367.question.ITestQuestionListGenerator;
import edu.chalmers.se.tda367.question.MathQuestionConFig;
import edu.chalmers.se.tda367.question.TestQuestionListGenerator;

/**
 * @author pierrereimertz
 */
public class TestController {

    public void startTest(User u) {
        MathQuestionConFig mqc = new MathQuestionConFig();
        mqc.setLevel(u.getLevel());
        Test t = Test.getInstance();
        ITestQuestionListGenerator TQLG = TestQuestionListGenerator.newInstance();
        t.setQuestions(TQLG.getQuestionList(mqc));
        t.startTest(t);
    }

    public void redoTest() {
        Test t = Test.getInstance();
        for (int i = 0; i < t.getQuestions().size(); i++) {
            t.getQuestions().get(i).notAnswered();

        }
        t.startTest(t);
    }
}
